<?php

use Lg\View\CssBlock;
use Lg\View\JsBlock;
use Lg\View\Asset;

CssBlock::begin();
?>
<style>
    @import url("<?php echo root_url('/assets/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css'); ?>");
    @import url("<?php echo root_url('/assets/jquery-upload-file/css/uploadfile.css'); ?>");
</style>
<?php CssBlock::end(); ?>
<?php echo get_header(); ?>
<form class="form-horizontal" action="" method="post">

    <div class="row">        
        <div class="col-md-12">
            <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">              
                    <li class="nav-item" ><a href="#settings" class="nav-link active" data-toggle="tab" aria-expanded="true">个人信息</a></li>
                    <li class="nav-item" ><a href="#account" class="nav-link" data-toggle="tab" aria-expanded="false">账户信息</a></li>
                    <li class="nav-item" ><a href="#profile" class="nav-link " data-toggle="tab" aria-expanded="false">Activity</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane" id="profile">
                        <div class="card">
                            <div class="card-block">                                   
                                <h3 class="profile-username text-center"><img class="profile-user-img img-responsive img-circle" height="36" src="<?php echo get_avatar(); ?>" alt="<?php echo h1cms\system\Auth::user()->display_name; ?>"> <?php echo h1cms\system\Auth::user()->display_name; ?></h3>                                
                                <table class="table table-bordered" style="background-color:#fff;font-size: 12px;">
                                    <tr>
                                        <th>角色</th>
                                        <td><?php echo join(' ,', get_roles_text()); ?></td>
                                    </tr>
                                    <tr>
                                        <th>创建时间</th>
                                        <td><?php echo format_date($user->created_at, 'long'); ?></td>
                                    </tr>
                                    <tr>
                                        <th>最后登录时间</th>
                                        <td><?php echo format_date($user->lasttime, 'long'); ?></td>
                                    </tr>
                                    <tr>
                                        <th>最后登录IP</th>
                                        <td><?php echo $user->lastip; ?></td>
                                    </tr>
                                </table>


                            </div>
                            <!-- /.box-body -->
                        </div>
                    </div>
                    <div class="tab-pane" id="account">
                        <div class="form-group row">
                            <label for="username" class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="username" id="username" placeholder="请输入用户名" value="<?php echo $user->username; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="email" class="col-sm-2 control-label">Email</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="email" id="email" placeholder="请输入Email" value="<?php echo $user->email; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="password" class="col-sm-2 control-label">密码</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="password" id="password" placeholder="请输入密码" value="">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="repassword" class="col-sm-2 control-label">确认密码</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="repassword" id="repassword" placeholder="请再次输入密码" value="">
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-danger">保存</button>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane active" id="settings">
                        <div class="form-group row">
                            <label for="display_name" class="col-sm-2 control-label">昵称</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user[display_name]" id="display_name" placeholder="昵称" value="<?php echo $user->display_name; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="first_name" class="col-sm-2 control-label">名字</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user_profile[first_name]" id="first_name" placeholder="名字" value="<?php echo $user_profile->first_name; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="last_name" class="col-sm-2 control-label">姓氏</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user_profile[last_name]" id="last_name" placeholder="姓氏" value="<?php echo $user_profile->last_name; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-10 ">                
                                <input type="radio" name="user_profile[sex]" id="sex1" value="1" <?php echo $user_profile->sex ? 'checked' : ''; ?>>
                                <label for="sex1">
                                    男
                                </label>
                                <input type="radio" name="user_profile[sex]" id="sex2" value="0" <?php echo $user_profile->sex ? '' : 'checked'; ?>>
                                <label for="sex2">
                                    女
                                </label>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="birthday" class="col-sm-2 control-label">生日</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user_profile[birthday]" id="birthday" placeholder="生日" value="<?php echo $user_profile->birthday; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="company" class="col-sm-2 control-label">公司</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user_profile[company]" id="company" placeholder="公司" value="<?php echo $user_profile->company; ?>">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="job_title" class="col-sm-2 control-label">职位</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="user_profile[job_title]" id="job_title" placeholder="职位" value="<?php echo $user_profile->job_title; ?>">
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="about" class="col-sm-2 control-label">简介</label>

                            <div class="col-sm-10">
                                <textarea class="form-control" name="user_profile[about]" id="about" placeholder="简介"><?php echo $user_profile->about; ?></textarea>
                            </div>
                        </div>

                        <div class="form-group row">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-danger">保存</button>
                            </div>
                        </div>

                    </div>
                    <!-- /.tab-pane -->

                </div>
                <!-- /.tab-content -->
            </div>
            <!-- /.nav-tabs-custom -->
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->


</form>
<?php
Asset::addJs(root_url('/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js'), Asset::BODY_END);
Asset::addJs(root_url('/assets/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js'), Asset::BODY_END);
Asset::addJs('//cdn.bootcss.com/jquery.form/3.51/jquery.form.min.js', Asset::BODY_END);
Asset::addJs(root_url('/assets/jquery-upload-file/js/jquery.uploadfile.min.js'), Asset::BODY_END);
JsBlock::begin(Asset::BODY_END);
?>
<script type="text/javascript">
    $(function () {
        $('#birthday').datetimepicker({
            initialDate: "1990-01-01",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            minView: 2,
            autoclose: true
        });
        $("#fileuploader").uploadFile({
            url: "<?php echo url_for('/users/?action=avatar'); ?>",
            multiple: false,
            maxFileCount: 1,
            fileName: "avatar_file",
            allowedTypes: "jpg,png,gif",
            uploadStr: "选择头像",
            abortStr: "取消上传",
            cancelStr: "取消",
            deletelStr: "删除",
            doneStr: "完成",
            dragDropStr: "<span><b>拖动文件到这里.</b></span>",
            multiDragErrorStr: "不支持多文件上传.",
            extErrorStr: "不支持的扩展: ",
            duplicateErrorStr: "文件已存在.",
            sizeErrorStr: "超出最大尺寸: ",
            uploadErrorStr: "不允许上传",
            maxFileCountErrorStr: " 超出最大文件上传数量:",
            downloadStr: "下载",
            customErrorKeyStr: "jquery-upload-file-error",
            onSuccess: function (files, data, xhr, pd)
            {
                console.log(files);
                console.log(data);
                console.log(xhr);
                console.log(pd);
                //files: list of files
                //data: response from server
                //xhr : jquer xhr object
            }
        });
    });
</script>
<?php JsBlock::end(); ?>
<?php echo get_footer(); ?>
